package com.lkd.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.lkd.dto.VmTypePageDto;
import com.lkd.entity.VmType;
import com.lkd.mapper.VmTypeMapper;
import com.lkd.result.PageBean;
import com.lkd.result.Result;
import com.lkd.service.VmTypeService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class VmTypeServiceImpl implements VmTypeService {
    //注入Mapper
    private final VmTypeMapper vmTypeMapper;

    @Override
    //分页查询
    public PageBean list(VmTypePageDto vmTypePageDto) {
        PageHelper.startPage(vmTypePageDto.getPageIndex(),vmTypePageDto.getPageSize());
        List<VmType> list = vmTypeMapper.list(vmTypePageDto);
        Page<VmType> page = (Page<VmType>) list;
        return new PageBean(page.getPageNum(),page.getPageSize(), (long) page.getPages(),page.getTotal(),page.getResult());
    }

    //新增设备类型
    @Override
    public Boolean save(VmType vmType) {
        return vmTypeMapper.save(vmType);
    }

    //修改设备类型
    @Override
    public Boolean update(VmType vmType) {
        return vmTypeMapper.update(vmType);
    }

    //删除设备类型
    @Override
    public Boolean delete(Integer typeId) {
        return vmTypeMapper.delete(typeId);
    }
}
